package com.wabbei.friendcenter.action;

import java.util.List;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;

import com.webbei.friendcenter.service.MyFriendCenter;
import com.webbei.pojo.Commission;
import com.webbei.pojo.Customs;
import com.webbei.pojo.Orders;

public class ChestAction {
	
	private String uname;
	private List<Commission> commission;
	private List<Commission> commissionfromcustom;
	private List<Orders> custom;//my cost money message----my money part
	private MyFriendCenter friservice;
	private double customAllMoney;
	private double commissionAllMoney;
	
	public String twoListfind(){
		uname=(String)ServletActionContext.getContext().getSession().get("username");
		
		//----------money from orders------------------
		customAllMoney=0.0;
		custom=friservice.getCostMoneyMessageByUserName(uname);
		for(Orders o:custom){
			customAllMoney+=o.getOrderTotalPrice();
		}
		//----------money from be shared------------------
		commissionAllMoney=0.0;
		commission=friservice.getAllCommissionByUserName(uname);//from  order
		commissionfromcustom=friservice.getAllCommissionFromCustomByUserName(uname);
		
		for(Commission m:commission){
			commissionAllMoney+=m.getGetMoney();
		}
		for(Commission m:commissionfromcustom){
			commissionAllMoney+=m.getGetMoney();
		}
		return "list";  
	}
	
	public List<Commission> getCommissionfromcustom() {
		return commissionfromcustom;
	}
	public void setCommissionfromcustom(List<Commission> commissionfromcustom) {
		this.commissionfromcustom = commissionfromcustom;
	}
	public String execute(){
		return null;
	}
	public double getCustomAllMoney() {
		return customAllMoney;
	}
	public void setCustomAllMoney(double customAllMoney) {
		this.customAllMoney = customAllMoney;
	}
	public double getCommissionAllMoney() {
		return commissionAllMoney;
	}
	public void setCommissionAllMoney(double commissionAllMoney) {
		this.commissionAllMoney = commissionAllMoney;
	}
	/*public MyFriendCenter getFriservice() {
		use $.getJSON() this method can't have
		return friservice;
	}*/
	public void setFriservice(MyFriendCenter friservice) {
		this.friservice = friservice;
	}
	public List<Commission> getCommission() {
		return commission;
	}
	public void setCommission(List<Commission> commission) {
		this.commission = commission;
	}
	public List<Orders> getCustom() {
		return custom;
	}
	public void setCustom(List<Orders> custom) {
		this.custom = custom;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	
}
